Skip to content

Conversation

@MeikelLP
Copy link

This PR brings basic functionality for C# method params in the source generator. Basically supporting methods like this:

[LuaMember]
public static LuaTable ParamsMethod(params LuaValue[] arguments)
{
    var table = new LuaTable(arguments.Length, arguments.Length);
    for (int i = 0; i < arguments.Length; i++)
    {
        // lua starts at 1
        table[i + 1] = arguments[i];
    }

    return table;
}

I tested this use case and tried to not break anything else while doing it. I cannot confirm that all use cases are covered. I will try other use cases too in the future. Please see this as a proof of work and not a fully fledged feature.

I'm implementing this because my Lua integration needs this feature. I'm testing this PR in my project and will apply further fixes if necessary.

@MeikelLP
Copy link
Author

@Akeit0 I saw you are actively working on the v0.5 branch. I implemented this PR also on the v0.5 branch.

Feel free to check it out: https://github.com/MeikelLP/Lua-CSharp/tree/feature/params-v5
You could also merge it into v0.5 and fix any issues that might arise from that on :)

@Akeit0
Copy link
Collaborator

Akeit0 commented Jun 3, 2025

It seems good.
But we need to consider that the cancellationtoken coming last is incompatible with params...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants